#ifndef __LINX_RANDOM_H
#define __LINX_RANDOM_H

#define USE_DEV_ENTROPY_SOURCE 1
#define USE_CPU_ENTROPY_SOURCE 1

#define ERANDOM_STATE ECANCELED

/**
 * @brief random generator init
 * 
 * @return int init success return 0, or error code
 */
int linx_random_init();

/**
 * @brief random generator reseed
 * 
 * @param opt optional input entropy
 * @param len input entropy len
 * @return int success return 0, or error code
 */
int linx_random_reseed(void* opt, const int len);

/**
 * @brief random generate
 * 
 * @param random [output]
 * @param len    random len
 * @return int success return 0, or error code
 */
int linx_random(unsigned char* random, const unsigned int len);

/**
 * @brief 重复计数测试
 * 
 * @return int success return 0, or error code
 */
int linx_random_recount_test();

/**
 * @brief 自适应比例测试
 * 
 * @return int success return 0, or error code
 */
int linx_random_adaptive_scale_test();

#ifndef linx_debug
#ifdef DEBUG
#ifdef __KERNEL__
#define linx_debug(format, ...)                          \
    do{                                                  \
        printk(KERN_INFO "[file:%s func:%s line:%d]. ",  \
                __FILE__, __FUNCTION__,  __LINE__);      \
        printk(KERN_INFO format, ##__VA_ARGS__);         \
    }while (0)
#else
#define linx_debug(format, ...)                         \
    do{                                                 \
        fprintf(stderr, "[file:%s func:%s line:%d]. ",  \
                __FILE__, __FUNCTION__, __LINE__);      \
        fprintf(stderr, format, ##__VA_ARGS__);         \
    }while (0)
#endif
#else
#define linx_debug(format, ...)
#endif
#endif

#endif /* __LINX_RANDOM_H */